package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.TUser;

@Mapper
public interface TUserDao {

    @Select("select * from t_user t where t.id = #{id}")
    TUser getById(Long id);

    @Delete("delete from t_user where id = #{id}")
    int delete(Long id);

    int update(TUser tUser);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into t_user(user_id, openid, nickname, headimgurl, sex, phone, province, city, country, create_time, update_time, state) values(#{userId}, #{openid}, #{nickname}, #{headimgurl}, #{sex}, #{phone}, #{province}, #{city}, #{country}, #{createTime}, #{updateTime}, #{state})")
    int save(TUser tUser);
    
    int count(@Param("params") Map<String, Object> params);

    List<TUser> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
